//
//  DetailHeadView.m
//  MyItem
//
//  Created by SoulWater on 16/1/14.
//  Copyright © 2016年 admin. All rights reserved.
//

#import "DetailHeadView.h"

@implementation DetailHeadView

-(void)awakeFromNib
{
    [super awakeFromNib];
    
   // [self createView];
    
}

-(void)setStoryModel:(StoryModel *)storyModel
{
    if (_storyModel != storyModel) {
        
        _storyModel = storyModel;
        
//        [self setNeedsLayout];
        [self createView];
    }
}

-(void)createView {

    NSString *iconStr = self.storyModel.pubUserImg;
    NSString *newString = [iconStr substringToIndex:iconStr.length-5];

    [_iconView sd_setImageWithURL:[NSURL URLWithString:newString]];
    _iconView.layer.cornerRadius = 35;
    _iconView.layer.masksToBounds = YES;
    
    _nickLabel.text = self.storyModel.pubUserName;
    
    _bodyLabel.text = self.storyModel.body;
    _bodyLabel.numberOfLines = 0;


    //计算label高度
    NSDictionary *attribut = @{NSFontAttributeName:[UIFont systemFontOfSize:16]};
    
    CGRect rect = [self.storyModel.body boundingRectWithSize:CGSizeMake(HScreenWidth-16, 1000) options:NSStringDrawingUsesLineFragmentOrigin attributes:attribut context:NULL];
    
    _bodyLabel.height = rect.size.height;

    self.bottom = _bodyLabel.bottom;

    self.viewHeight = _bodyLabel.bottom;


}


@end
